from .mysql_func_mod import Methods

import asyncio

met = Methods()

class Orders_insert() :

    async def ord_ins(self,user_id, merchat_id, orders) :

        insert_sql = '''
            INSERT INTO orders 
            (user_id,merchat_id,orders)
            VALUES
            (%s,%s,%s)
            '''
        # 判断参数有没有缺少，如果参数没有缺少就执行SQL
        if all([user_id, merchat_id, orders]):
            result_info = await met.insert_info(insert_sql, (user_id, merchat_id, orders))
            if result_info == 'ok':
                return {
                    'status': 1,
                    'errorCode': None,
                    'errorMsg': None,
                    'resultBody': '插入成功',
                }
            else:
                return {
                    'status': -1,
                    'errorCode': 4,
                    'errorMsg': '请检查你的参数',
                    'resultBody': None,
                }
        else:
            return {
                'status': -1,
                'errorCode': 3,
                'errorMsg':"参数不完整",
                'resultBody': None,
            }

